﻿using HalconDotNet;
using IniReadWrite;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VisionRoc.Core
{
    public class SetRectangle2
    {
        string Rectangle2Path;
        public SetRectangle2(string _Path)
        {
            //判断文件路径是否存在
            if (!Directory.Exists(_Path))
            {
                Directory.CreateDirectory(_Path);
            }

            Rectangle2Path = _Path + "\\Rectangle2.ini";
            if (File.Exists(Rectangle2Path))
            {
                //ReadRectangle2Parameter();
            }

        }


        [Browsable(true), Description("绘制区域输出Row参数"), Category("绘制区域参数"), ReadOnly(false)]
        public double Row { get; set; }

        [Browsable(true), Description("绘制区域输出Col数"), Category("绘制区域参数"), ReadOnly(false)]
        public double Col { get; set; }

        [Browsable(true), Description("绘制区域输出Phi参数 半径较大的半轴的方向。"), Category("绘制区域参数"), ReadOnly(false)]
        public double Phi { get; set; }

        [Browsable(true), Description("绘制区域输出Length1参数"), Category("绘制区域参数"), ReadOnly(false)]
        public double Length1 { get; set; }

        [Browsable(true), Description("绘制区域输出Length2参数"), Category("绘制区域参数"), ReadOnly(false)]
        public double Length2 { get; set; }



        /// <summary>
        /// 保存矩形2参数
        /// </summary>
        public void WriteRectangle2Parameter()
        {
            IniAPI.INIWriteValue(Rectangle2Path, "Rectangle2Parameter", "DrawRow", Row.ToString());
            IniAPI.INIWriteValue(Rectangle2Path, "Rectangle2Parameter", "DrawCol", Col.ToString());
            IniAPI.INIWriteValue(Rectangle2Path, "Rectangle2Parameter", "DrawPhi", Phi.ToString());
            IniAPI.INIWriteValue(Rectangle2Path, "Rectangle2Parameter", "DrawLength1", Length1.ToString());
            IniAPI.INIWriteValue(Rectangle2Path, "Rectangle2Parameter", "DrawLength2", Length2.ToString());
        }

        /// <summary>
        /// 读取矩形2参数
        /// </summary>
        public void ReadRectangle2Parameter()
        {
            try
            {
                Row = Convert.ToDouble(IniAPI.INIGetStringValue(Rectangle2Path, "Rectangle2Parameter", "DrawRow", "0"));
                Col = Convert.ToDouble(IniAPI.INIGetStringValue(Rectangle2Path, "Rectangle2Parameter", "DrawCol", "0"));
                Phi = Convert.ToDouble(IniAPI.INIGetStringValue(Rectangle2Path, "Rectangle2Parameter", "DrawPhi", "0"));
                Length1 = Convert.ToDouble(IniAPI.INIGetStringValue(Rectangle2Path, "Rectangle2Parameter", "DrawLength1", "0"));
                Length2 = Convert.ToDouble(IniAPI.INIGetStringValue(Rectangle2Path, "Rectangle2Parameter", "DrawLength2", "0"));
            }
            catch { }

        }
    }
}
